#include <sstream>
#include "TProfile.h"
#define binNumber 20

void plot()
{
	gStyle->SetOptStat(0);
	TFile *f1 = new TFile("result.root");

//	TCanvas *c1 = new TCanvas();
//	Ncol_draw();

//	pt2d_draw();

//	ptN_draw();

//	TCanvas *c4 = new TCanvas();
//	phi2d_draw();

//	phi_draw();
	
//	v2_draw();
//	v2_n_draw();
//	v2_pt_draw();
//	v2_N();
//	rptN_draw();
        nVsDpt_draw();

}
	
	
void Ncol_draw()
{
	TH1F *Ncol_init_low = (TH1F *)gROOT->FindObject("Ncol_init_low");
        TH1F *Ncol_init_high = (TH1F *)gROOT->FindObject("Ncol_init_high");
        TH1F *Ncol_final_low = (TH1F *)gROOT->FindObject("Ncol_final_low");
        TH1F *Ncol_final_high = (TH1F *)gROOT->FindObject("Ncol_final_high");
	Ncol_init_low->Sumw2();
	Ncol_init_high->Sumw2();
	Ncol_final_low->Sumw2();
	Ncol_final_high->Sumw2();
	Ncol_init_low->Scale(1./Ncol_init_low->Integral());
	Ncol_init_high->Scale(1./Ncol_init_high->Integral());
	Ncol_final_low->Scale(1./Ncol_final_low->Integral());
	Ncol_final_high->Scale(1./Ncol_final_high->Integral());


	
	TMultiGraph *mg = new TMultiGraph();
	int nc = 10;
	double x[4][10],y[4][10],ex[4][10],ey[4][10];
	for(int j=0;j<10;j++)
	{
		for(int i=0;i<4;i++)
		{
			x[i][j] = j;
			ex[i][j] = 0;
		}
		y[0][j] = Ncol_init_low->GetBinContent(j+1);
		y[1][j] = Ncol_init_high->GetBinContent(j+1);
		y[2][j] = Ncol_final_low->GetBinContent(j+1);
		y[3][j] = Ncol_final_high->GetBinContent(j+1);
		ey[0][j] = Ncol_init_low->GetBinError(j+1);
		ey[1][j] = Ncol_init_high->GetBinError(j+1);
		ey[2][j] = Ncol_final_low->GetBinError(j+1);
		ey[3][j] = Ncol_final_high->GetBinError(j+1);
	}

	TGraphErrors *gr0 = new TGraphErrors(nc,x[0],y[0],ex[0],ey[0]);
	gr0->SetLineColor(1);
	gr0->SetLineStyle(2);
	gr0->SetMarkerColor(1);
	gr0->GetXaxis()->SetTitle("Number of Collision");	
	mg->Add(gr0);
	TGraphErrors *gr1 = new TGraphErrors(nc,x[1],y[1],ex[1],ey[1]);
	gr1->SetLineStyle(2);
	gr1->SetLineColor(2);
	gr1->SetMarkerColor(2);
	gr1->GetXaxis()->SetTitle("Number of Collision");	
	mg->Add(gr1);
	TGraphErrors *gr2 = new TGraphErrors(nc,x[2],y[2],ex[2],ey[2]);
	gr2->SetLineColor(1);
	gr2->SetMarkerColor(1);
	mg->Add(gr2);
	TGraphErrors *gr3 = new TGraphErrors(nc,x[3],y[3],ex[3],ey[3]);
	gr3->SetLineColor(2);
	gr3->SetMarkerColor(2);
	mg->Add(gr3);

        leg2 = new TLegend(0.5,0.7,0.9,0.9);
        leg2->SetFillColor(0);
        leg2->SetHeader("Ncoll distribution with different pT");
        leg2->AddEntry(gr0,"N_{coll}, Initial P_{T}<0.5 GeV","lpe");
        leg2->AddEntry(gr1,"N_{coll}, Initial P_{T}>3 GeV","lpe");
        leg2->AddEntry(gr2,"N_{coll}, Final P_{T}<0.5 GeV","lpe");
        leg2->AddEntry(gr3,"N_{coll}, Final P_{T}>3 GeV","lpe");

	mg->Draw("apl");	
        leg2->Draw("same");

	
}

void pt2d_draw()
{
	TCanvas *c2 = new TCanvas();
        TH2D *pt_i_f = (TH2D *)gROOT->FindObject("Final_init_pt");	
	pt_i_f->GetXaxis()->SetTitle("initial P_{T}");
	pt_i_f->GetYaxis()->SetTitle("final P_{T}");
	pt_i_f->Draw("box");
	TCanvas *c21 = new TCanvas();
	float l_pt_x[100];
	float l_pt_y[100];
	float m_pt_x[100];
	float m_pt_y[100];
	float h_pt_x[100];
	float h_pt_y[100];
	float ex[100],ey[100];
	TH1D *low  = pt_i_f->ProjectionX("pt",0,10);
//	low->Scale(1./low->Integral());
	for(int i=0;i<100;i++)
	{
		l_pt_x[i] = 0.1*i;
		l_pt_y[i] = low->GetBinContent(i+1);
		if(l_pt_y[i]>0.00001)
		l_pt_y[i] = log10(l_pt_y[i]);
	}
	TH1D *mid  = pt_i_f->ProjectionX("pt",10,40);
//	low->Scale(1./low->Integral());
	for(int i=0;i<100;i++)
	{
		m_pt_x[i] = 0.1*i;
		m_pt_y[i] = mid->GetBinContent(i+1);
		if(m_pt_y[i]>0.00001)
		m_pt_y[i] = log10(m_pt_y[i]);
	}
	TH1D *high  = pt_i_f->ProjectionX("pt",40,100);
//	high->Scale(1./high->Integral());	
	for(int i=0;i<100;i++)
	{
		h_pt_x[i] = 0.1*i;
		h_pt_y[i] = low->GetBinContent(i+1);
		if(h_pt_y[i]>0.00001)
		h_pt_y[i] = log10(h_pt_y[i]);
		ex[i] = 0;
		ey[i] = 0;
	}
	int nc = 100;
	TMultiGraph *mg = new TMultiGraph();
	TGraphErrors *gr0 = new TGraphErrors(100,l_pt_x,l_pt_y,ex,ey);
	mg->Add(gr0);
	TGraphErrors *gr1 = new TGraphErrors(100,m_pt_x,m_pt_y,ex,ey);
	gr1->SetLineColor(2);
	gr1->SetMarkerColor(2);
	mg->Add(gr1);
	TGraphErrors *gr2 = new TGraphErrors(100,h_pt_x,h_pt_y,ex,ey);
	gr2->SetLineColor(4);
	gr2->SetMarkerColor(4);
	mg->Add(gr2);

	leg = new TLegend(0.5,0.7,0.9,0.9);
	leg->SetFillColor(0);
        leg->AddEntry(gr0,"P_{T}^{Initial} < 1GeV","lpe");
        leg->AddEntry(gr1,"1GeV<P_{T}^{Initial}<4GeV","lpe");
        leg->AddEntry(gr2,"P_{T}^{Initial}>4GeV","lpe");
	mg->Draw("apl");
	leg->Draw("same");
	
}

void ptN_draw()
{
	//TCanvas *c = new TCanvas();	
	//c->Divide(2,2);
	TMultiGraph *mmg = new TMultiGraph();
        TH2F *dptvsN_1 = (TH2F *)gROOT->FindObject("rptvsN_1");
        TH2F *dptvsN_2 = (TH2F *)gROOT->FindObject("rptvsN_2");
        TH2F *dptvsN_3 = (TH2F *)gROOT->FindObject("rptvsN_3");
        TH2F *dptvsN_4 = (TH2F *)gROOT->FindObject("rptvsN_4");
        TProfile *prof_dptvsN_1 = dptvsN_1->ProfileX();
        TProfile *prof_dptvsN_2 = dptvsN_2->ProfileX();
        TProfile *prof_dptvsN_3 = dptvsN_3->ProfileX();
        TProfile *prof_dptvsN_4 = dptvsN_4->ProfileX();

	int nc = 10;
	double x[4][10],y[4][10],ex[4][10],ey[4][10];
	for(int j=0;j<10;j++)
	{
		for(int i=0;i<4;i++)
		{
			x[i][j] = j;
			ex[i][j] = 0;
		}
		y[0][j] = prof_dptvsN_1->GetBinContent(j+1);
		y[1][j] = prof_dptvsN_2->GetBinContent(j+1);
		y[2][j] = prof_dptvsN_3->GetBinContent(j+1);
		y[3][j] = prof_dptvsN_4->GetBinContent(j+1);
		ey[0][j] = prof_dptvsN_1->GetBinError(j+1);
		ey[1][j] = prof_dptvsN_2->GetBinError(j+1);
		ey[2][j] = prof_dptvsN_3->GetBinError(j+1);
		ey[3][j] = prof_dptvsN_4->GetBinError(j+1);
	}
	y[0][0] = 0;
	y[1][0] = 0;
	y[2][0] = 0;
	y[3][0] = 0;

	TGraphErrors *gr0 = new TGraphErrors(nc,x[0],y[0],ex[0],ey[0]);
	gr0->GetXaxis()->SetTitle("Number of Collision");	
	gr0->GetYaxis()->SetTitle("(P_{T}^{final}-P_{T}^{initial})/(P_{T}^{initial}-<P_{T}>");	
        gr0->SetTitle("Initial P_{T} < 0.2GeV");
	mmg->Add(gr0);


	TGraphErrors *gr1 = new TGraphErrors(nc,x[1],y[1],ex[1],ey[1]);
	gr1->GetXaxis()->SetTitle("Number of Collision");	
	gr1->GetYaxis()->SetTitle("(P_{T}^{final}-P_{T}^{initial})/(P_{T}^{initial}-<P_{T}>");	
        gr1->SetTitle("Initial P_{T} > 1GeV");
        gr1->SetLineColor(2);
        gr1->SetMarkerColor(2);
	mmg->Add(gr1);


	TGraphErrors *gr2 = new TGraphErrors(nc,x[2],y[2],ex[2],ey[2]);
	gr2->GetXaxis()->SetTitle("Number of Collision");	
	gr2->GetYaxis()->SetTitle("(P_{T}^{final}-P_{T}^{initial})/(P_{T}^{initial}-<P_{T}>");	
        gr2->SetTitle("Initial P_{T} > 2GeV");
        gr2->SetLineColor(3);
        gr2->SetMarkerColor(3);
	mmg->Add(gr2);


	TGraphErrors *gr3 = new TGraphErrors(nc,x[3],y[3],ex[3],ey[3]);
	gr3->GetXaxis()->SetTitle("Number of Collision");	
	gr3->GetYaxis()->SetTitle("(P_{T}^{final}-P_{T}^{initial})/(P_{T}^{initial}-<P_{T}>");	
        gr3->SetTitle("Initial P_{T} > 3GeV");
        gr3->SetLineColor(4);
        gr3->SetMarkerColor(4);
	mmg->Add(gr3);


	leg0 = new TLegend(0.5,0.7,0.95,0.9);
        leg0->SetFillColor(0);
        leg0->AddEntry(gr0,"Initial P_{T}<0.2GeV","lpe");
        leg0->AddEntry(gr1,"Initial P_{T}>1GeV","lpe");
        leg0->AddEntry(gr2,"Initial P_{T}>2GeV","lpe");
        leg0->AddEntry(gr3,"Initial P_{T}>3GeV","lpe");
	mmg->Draw("apl");
        leg0->Draw("same");
/*
        c->cd(1);
        gr0->Draw("apl");
        c->cd(2);
        gr1->Draw("apl");
        c->cd(3);
        gr2->Draw("apl");
        c->cd(4);
        gr3->Draw("apl");	
*/
}


void phi2d_draw()
{
        TH2D *phi_i_f = (TH2D *)gROOT->FindObject("Final_init_phi");	
	phi_i_f->GetXaxis()->SetTitle("initial #phi");
	phi_i_f->GetYaxis()->SetTitle("final #phi");
	phi_i_f->Draw();
}

void phi_draw()
{
	TCanvas *c5 = new TCanvas();	
	c5->Divide(2,2);

        TH1F *init_phi_1 = (TH1F *)gROOT->FindObject("initial_phi_0");
        TH1F *init_phi_2 = (TH1F *)gROOT->FindObject("initial_phi_1");
        TH1F *init_phi_3 = (TH1F *)gROOT->FindObject("initial_phi_2");
        TH1F *init_phi_4 = (TH1F *)gROOT->FindObject("initial_phi_3");
	int nc = 50;
	double x[4][50],y[4][50],ex[4][50],ey[4][50];
	for(int j=0;j<50;j++)
	{
		for(int i=0;i<4;i++)
		{
			x[i][j] = 3.1416/25*j-3.1416;
			ex[i][j] = 0;
		}
		y[0][j] = init_phi_1->GetBinContent(j+1);
		y[1][j] = init_phi_2->GetBinContent(j+1);
		y[2][j] = init_phi_3->GetBinContent(j+1);
		y[3][j] = init_phi_4->GetBinContent(j+1);
		ey[0][j] = init_phi_1->GetBinError(j+1);
		ey[1][j] = init_phi_2->GetBinError(j+1);
		ey[2][j] = init_phi_3->GetBinError(j+1);
		ey[3][j] = init_phi_4->GetBinError(j+1);
	}

	TGraphErrors *gr0 = new TGraphErrors(nc,x[0],y[0],ex[0],ey[0]);
	gr0->GetXaxis()->SetTitle("Initial #phi");	
	gr0->SetTitle("# of Collision = 0");
	TGraphErrors *gr1 = new TGraphErrors(nc,x[1],y[1],ex[1],ey[1]);
	gr1->GetXaxis()->SetTitle("Initial #phi");	
	gr1->SetTitle("# of Collision = 1");
	TGraphErrors *gr2 = new TGraphErrors(nc,x[2],y[2],ex[2],ey[2]);
	gr2->GetXaxis()->SetTitle("Initial #phi");	
	gr2->SetTitle("# of Collision = 2");
	TGraphErrors *gr3 = new TGraphErrors(nc,x[3],y[3],ex[3],ey[3]);
	gr3->GetXaxis()->SetTitle("Initial #phi");	
	gr3->SetTitle("# of Collision >= 3");


        c5->cd(1);
        gr0->Draw("apl");
        c5->cd(2);
        gr1->Draw("apl");
        c5->cd(3);
        gr2->Draw("apl");
        c5->cd(4);
        gr3->Draw("apl");	
}

void v2_draw()
{
	TH3F *v2[4];//0-i-v2-i-pt; 1-f-v2-i-pt; 2-i-v2-f-pt; 3-f-v2-f-pt
	v2[0] = (TH3F *)gROOT->FindObject("init_cos_init_pt_n");
	v2[1] = (TH3F *)gROOT->FindObject("final_cos__init_pt_n");
	v2[2] = (TH3F *)gROOT->FindObject("init_cos_final_pt_n");
	v2[3] = (TH3F *)gROOT->FindObject("final_cos_fianl_pt_n");
////////////////Start to work with v2 vs # of collisions//////////////////////
	TH2F *v2_n[3][4];//[0][*]-(0.0.5GeV); [1][*]-(1GeV,2GeV); [2][*]-(2GeV, 10GeV)
	TProfile *prof_v2_n[3][4];//[0][*]-(0.0.5GeV); [1][*]-(1GeV,2GeV); [2][*]-(2GeV, 10GeV)
	float a[6] = {1,5,11,20,21,34};//it's use to control pt region
//	float a[6] = {0,0.5,1,2,2,10};//it's use to control pt region
	float nx[10]; float nex[10];
	float ny[3][4][10];  
	float ney[3][4][10];  
	for(int i=0;i<4;i++)//here i is for control initial/final v2 and pt
	{
		for(int j=0;j<3;j++)//herej is to control pt region	
		{
			v2[i]->GetYaxis()->SetRange(a[j*2],a[j*2+1]);
			TH2F *h = v2[i]->Project3D("zx");
			prof_v2_n[j][i] = h->ProfileX();
			for(int k=0;k<10;k++)
			{
				ny[j][i][k] = prof_v2_n[j][i]->GetBinContent(k+1);
				ney[j][i][k] = prof_v2_n[j][i]->GetBinError(k+1);
			}
		}
	}
	
////////////////Start to work with v2 vs # of collisions//////////////////////
	for(int k=0;k<10;k++)
	{
		nx[k] = k;
		nex[k] = 0;
	}
	TCanvas *cv1 = new TCanvas();
	TMultiGraph *v2_n_pti = new TMultiGraph();
	int nc = 10;
	TGraphErrors *i_v2_n_pti1 = new TGraphErrors(nc,nx,ny[0][0],nex,ney[0][0]);	
	cout<<"!!!!!!!!!!!!!!!!!!!!!"<<endl;
	i_v2_n_pti1->SetLineColor(1);
	i_v2_n_pti1->SetLineStyle(2);
	i_v2_n_pti1->SetMarkerColor(1);
	v2_n_pti->Add(i_v2_n_pti1);

	TGraphErrors *i_v2_n_pti2 = new TGraphErrors(nc,nx,ny[1][0],nex,ney[1][0]);	
	i_v2_n_pti2->SetLineColor(3);
	i_v2_n_pti2->SetLineStyle(2);
	i_v2_n_pti2->SetMarkerColor(1);
	v2_n_pti->Add(i_v2_n_pti2);

	TGraphErrors *i_v2_n_pti3 = new TGraphErrors(nc,nx,ny[2][0],nex,ney[2][0]);	
	i_v2_n_pti3->SetLineColor(4);
	i_v2_n_pti3->SetLineStyle(2);
	i_v2_n_pti3->SetMarkerColor(1);
	v2_n_pti->Add(i_v2_n_pti3);

	TGraphErrors *f_v2_n_pti1 = new TGraphErrors(nc,nx,ny[0][1],nex,ney[0][1]);	
	f_v2_n_pti1->SetLineColor(1);
	f_v2_n_pti1->SetMarkerColor(1);
	v2_n_pti->Add(f_v2_n_pti1);

	TGraphErrors *f_v2_n_pti2 = new TGraphErrors(nc,nx,ny[1][1],nex,ney[1][1]);	f_v2_n_pti2->SetLineColor(3); f_v2_n_pti2->SetMarkerColor(1); v2_n_pti->Add(f_v2_n_pti2);

	TGraphErrors *f_v2_n_pti3 = new TGraphErrors(nc,nx,ny[2][1],nex,ney[2][1]);	
	f_v2_n_pti3->SetLineColor(4);
	f_v2_n_pti3->SetMarkerColor(1);
	v2_n_pti->Add(f_v2_n_pti3);

        leg0 = new TLegend(0.5,0.7,0.95,0.9);
        leg0->SetFillColor(0);
        leg0->SetHeader("v2 vs Number of collisions in different initial P_{T} region");
        leg0->AddEntry(i_v2_n_pti1,"Initial v2, 0 GeV < P_{T} < 0.5 GeV","lpe");
        leg0->AddEntry(i_v2_n_pti2,"Initial v2, 1 GeV < P_{T} < 2 GeV","lpe");
        leg0->AddEntry(i_v2_n_pti3,"Initial v2, 2 GeV < P_{T} < 10 GeV","lpe");
        leg0->AddEntry(f_v2_n_pti1,"Final v2, 0 GeV < P_{T} < 0.5 GeV","lpe");
        leg0->AddEntry(f_v2_n_pti2,"Final v2, 1 GeV < P_{T} < 2 GeV","lpe");
        leg0->AddEntry(f_v2_n_pti3,"Final v2, 2 GeV < P_{T} < 10 GeV","lpe");

	v2_n_pti->Draw("apl");
	leg0->Draw("same");
////////////////////////////////////////////////////////////////////////////////////
	TCanvas *cv2 = new TCanvas();

	TMultiGraph *v2_n_ptf = new TMultiGraph();
	int nc = 10;
	TGraphErrors *i_v2_n_ptf1 = new TGraphErrors(nc,nx,ny[0][2],nex,ney[0][2]);	
	i_v2_n_ptf1->SetLineColor(1);
	i_v2_n_ptf1->SetLineStyle(2);
	i_v2_n_ptf1->SetMarkerColor(1);
	v2_n_ptf->Add(i_v2_n_ptf1);

	TGraphErrors *i_v2_n_ptf2 = new TGraphErrors(nc,nx,ny[1][2],nex,ney[1][2]);	
	i_v2_n_ptf2->SetLineColor(3);
	i_v2_n_ptf2->SetLineStyle(2);
	i_v2_n_ptf2->SetMarkerColor(1);
	v2_n_ptf->Add(i_v2_n_ptf2);

	TGraphErrors *i_v2_n_ptf3 = new TGraphErrors(nc,nx,ny[2][2],nex,ney[2][2]);	
	i_v2_n_ptf3->SetLineColor(4);
	i_v2_n_ptf3->SetLineStyle(2);
	i_v2_n_ptf3->SetMarkerColor(1);
	v2_n_ptf->Add(i_v2_n_ptf3);

	TGraphErrors *f_v2_n_ptf1 = new TGraphErrors(nc,nx,ny[0][3],nex,ney[0][3]);	
	f_v2_n_ptf1->SetLineColor(1);
	f_v2_n_ptf1->SetMarkerColor(1);
	v2_n_ptf->Add(f_v2_n_ptf1);

	TGraphErrors *f_v2_n_ptf2 = new TGraphErrors(nc,nx,ny[1][3],nex,ney[1][3]);	
	f_v2_n_ptf2->SetLineColor(3);
	f_v2_n_ptf2->SetMarkerColor(1);
	v2_n_ptf->Add(f_v2_n_ptf2);

	TGraphErrors *f_v2_n_ptf3 = new TGraphErrors(nc,nx,ny[2][3],nex,ney[2][3]);	
	f_v2_n_ptf3->SetLineColor(4);
	f_v2_n_ptf3->SetMarkerColor(1);
	v2_n_ptf->Add(f_v2_n_ptf3);

        leg1 = new TLegend(0.5,0.7,0.95,0.9);
        leg1->SetFillColor(0);
        leg1->SetHeader("v2 vs Number of collisions in different final P_{T} region");
        leg1->AddEntry(i_v2_n_ptf1,"Initial v2, 0 GeV < P_{T} < 0.5 GeV","lpe");
        leg1->AddEntry(i_v2_n_ptf2,"Initial v2, 1 GeV < P_{T} < 2 GeV","lpe");
        leg1->AddEntry(i_v2_n_ptf3,"Initial v2, 2 GeV < P_{T} < 10 GeV","lpe");
//        leg1->AddEntry(f_v2_n_ptf1,"Final v2, 0 GeV < P_{T} < 0.5 GeV","lpe");
//        leg1->AddEntry(f_v2_n_ptf2,"Final v2, 1 GeV < P_{T} < 2 GeV","lpe");
//        leg1->AddEntry(f_v2_n_ptf3,"Final v2, 2 GeV < P_{T} < 10 GeV","lpe");


	v2_n_ptf->Draw("apl");
	leg1->Draw("same");
////////////////Start to work with v2 vs PT of collisions//////////////////////

	TH2F *v2_pt[4][4];//[0][*]-(0.0.5GeV); [1][*]-(1GeV,2GeV); [2][*]-(2GeV, 10GeV)
	TProfile *prof_v2_pt[4][4];//[0][*]-(0.0.5GeV); [1][*]-(1GeV,2GeV); [2][*]-(2GeV, 10GeV)
	float b[8] = {1,1,2,2,3,3,4,10};//it's use to control pt region
//	float a[6] = {0,0.5,1,2,2,10};//it's use to control pt region
	float pty[4][4][34];  
	float ptey[4][4][34];  
	for(int i=0;i<4;i++)//here i is for control initial/final v2 and pt
	{
		for(int j=0;j<4;j++)//herej is to control N	
		{
			v2[i]->GetXaxis()->SetRange(b[j*2],b[j*2+1]);
			TH2F *h = v2[i]->Project3D("zy");
			prof_v2_pt[j][i] = h->ProfileX();
			for(int k=0;k<34;k++)
			{
				pty[j][i][k] = prof_v2_pt[j][i]->GetBinContent(k+1);
				ptey[j][i][k] = prof_v2_pt[j][i]->GetBinError(k+1);
			}
		}
	}
	TCanvas *xxx = new TCanvas();
	prof_v2_pt[0][0]->Draw();
	
////////////////Start to work with v2 vs # of collisions//////////////////////
        float ptx[35];
	float ptex[35];

        for(int i=0;i<20;i++)
             ptx[i] = 0.1*i;
        for(int i=20;i<30;i++)
             ptx[i] = 0.2*i-2.;
        ptx[30] = 4.;
        ptx[31] = 5.;
        ptx[32] = 6.;
        ptx[33] = 8.;
        ptx[34] = 10.;
	for(int k=0;k<35;k++)
	{
		ptex[k] = 0;
	}
	TCanvas *cv3 = new TCanvas();
	TMultiGraph *v2_pt_ni = new TMultiGraph();
	int nc = 34;
	TGraphErrors *i_v2_pt_ni1 = new TGraphErrors(nc,ptx,pty[0][0],ptex,ptey[0][0]);	
	cout<<"!!!!!!!!!!!!!!!!!!!!!"<<endl;
	i_v2_pt_ni1->SetLineColor(1);
	i_v2_pt_ni1->SetLineStyle(2);
	i_v2_pt_ni1->SetMarkerColor(1);
	v2_pt_ni->Add(i_v2_pt_ni1);

	TGraphErrors *i_v2_pt_ni2 = new TGraphErrors(nc,ptx,pty[1][0],ptex,ptey[1][0]);	
	i_v2_pt_ni2->SetLineColor(2);
	i_v2_pt_ni2->SetLineStyle(2);
	i_v2_pt_ni2->SetMarkerColor(2);
	v2_pt_ni->Add(i_v2_pt_ni2);

	TGraphErrors *i_v2_pt_ni3 = new TGraphErrors(nc,ptx,pty[2][0],ptex,ptey[2][0]);	
	i_v2_pt_ni3->SetLineColor(4);
	i_v2_pt_ni3->SetLineStyle(2);
	i_v2_pt_ni3->SetMarkerColor(4);
	v2_pt_ni->Add(i_v2_pt_ni3);

	TGraphErrors *i_v2_pt_ni4 = new TGraphErrors(nc,ptx,pty[3][0],ptex,ptey[3][0]);	
	i_v2_pt_ni3->SetLineColor(3);
	i_v2_pt_ni3->SetLineStyle(2);
	i_v2_pt_ni3->SetMarkerColor(3);
	v2_pt_ni->Add(i_v2_pt_ni4);

	TGraphErrors *f_v2_pt_ni1 = new TGraphErrors(nc,ptx,pty[0][1],ptex,ptey[0][1]);	
	f_v2_pt_ni1->SetLineColor(1);
	f_v2_pt_ni1->SetMarkerColor(1);
	v2_pt_ni->Add(f_v2_pt_ni1);

	TGraphErrors *f_v2_pt_ni2 = new TGraphErrors(nc,ptx,pty[1][1],ptex,ptey[1][1]);	
	f_v2_pt_ni2->SetLineColor(2);
	f_v2_pt_ni2->SetMarkerColor(2);
	v2_pt_ni->Add(f_v2_pt_ni2);

	TGraphErrors *f_v2_pt_ni3 = new TGraphErrors(nc,ptx,pty[2][1],ptex,ptey[2][1]);	
	f_v2_pt_ni3->SetLineColor(4);
	f_v2_pt_ni3->SetMarkerColor(3);
	v2_pt_ni->Add(f_v2_pt_ni3);

	TGraphErrors *f_v2_pt_ni4 = new TGraphErrors(nc,ptx,pty[3][1],ptex,ptey[3][1]);	
	f_v2_pt_ni3->SetLineColor(3);
	f_v2_pt_ni3->SetMarkerColor(4);
	v2_pt_ni->Add(f_v2_pt_ni4);

        leg2 = new TLegend(0.5,0.7,0.95,0.9);
        leg2->SetFillColor(0);
        leg2->SetHeader("v2 of partons with different N_{coll} vs initial P_{T} region");
        leg2->AddEntry(i_v2_pt_ni1,"Initial v2, N_{coll} = 0","lpe");
        leg2->AddEntry(i_v2_pt_ni2,"Initial v2, N_{coll} = 1","lpe");
        leg2->AddEntry(i_v2_pt_ni3,"Initial v2, N_{coll} = 2","lpe");
        leg2->AddEntry(i_v2_pt_ni4,"Initial v2, N_{coll} >= 3","lpe");
        leg2->AddEntry(f_v2_pt_ni1,"Final v2, N_{coll} = 0","lpe");
        leg2->AddEntry(f_v2_pt_ni2,"Final v2, N_{coll} = 1","lpe");
        leg2->AddEntry(f_v2_pt_ni3,"Final v2, N_{coll} = 2","lpe");
        leg2->AddEntry(f_v2_pt_ni4,"Final v2, N_{coll} >= 3","lpe");

	v2_pt_ni->Draw("apl");
	leg2->Draw("same");
////////////////////////////////////////////////////////////////////////////////////
	TCanvas *cv2 = new TCanvas();

	TMultiGraph *v2_pt_nf = new TMultiGraph();
	int nc = 34;
	TGraphErrors *i_v2_pt_nf1 = new TGraphErrors(nc,ptx,pty[0][2],ptex,ptey[0][2]);	
	i_v2_pt_nf1->SetLineColor(1);
	i_v2_pt_nf1->SetLineStyle(2);
	i_v2_pt_nf1->SetMarkerColor(1);
	v2_pt_nf->Add(i_v2_pt_nf1);

	TGraphErrors *i_v2_pt_nf2 = new TGraphErrors(nc,ptx,pty[1][2],ptex,ptey[1][2]);	
	i_v2_pt_nf2->SetLineColor(2);
	i_v2_pt_nf2->SetLineStyle(2);
	i_v2_pt_nf2->SetMarkerColor(2);
	v2_pt_nf->Add(i_v2_pt_nf2);

	TGraphErrors *i_v2_pt_nf3 = new TGraphErrors(nc,ptx,pty[2][2],ptex,ptey[2][2]);	
	i_v2_pt_nf3->SetLineColor(4);
	i_v2_pt_nf3->SetLineStyle(2);
	i_v2_pt_nf3->SetMarkerColor(4);
	v2_pt_nf->Add(i_v2_pt_nf3);

	TGraphErrors *i_v2_pt_nf4 = new TGraphErrors(nc,ptx,pty[3][2],ptex,ptey[3][2]);	
	i_v2_pt_nf3->SetLineColor(3);
	i_v2_pt_nf3->SetLineStyle(2);
	i_v2_pt_nf3->SetMarkerColor(3);
	v2_pt_nf->Add(i_v2_pt_nf4);

	TGraphErrors *f_v2_pt_nf1 = new TGraphErrors(nc,ptx,pty[0][3],ptex,ptey[0][3]);	
	f_v2_pt_nf1->SetLineColor(1);
	f_v2_pt_nf1->SetMarkerColor(1);
	v2_pt_nf->Add(f_v2_pt_nf1);

	TGraphErrors *f_v2_pt_nf2 = new TGraphErrors(nc,ptx,pty[1][3],ptex,ptey[1][3]);	
	f_v2_pt_nf2->SetLineColor(2);
	f_v2_pt_nf2->SetMarkerColor(2);
	v2_pt_nf->Add(f_v2_pt_nf2);

	TGraphErrors *f_v2_pt_nf3 = new TGraphErrors(nc,ptx,pty[2][3],ptex,ptey[2][3]);	
	f_v2_pt_nf3->SetLineColor(4);
	f_v2_pt_nf3->SetMarkerColor(4);
	v2_pt_nf->Add(f_v2_pt_nf3);

	TGraphErrors *f_v2_pt_nf4 = new TGraphErrors(nc,ptx,pty[3][3],ptex,ptey[3][3]);	
	f_v2_pt_nf3->SetLineColor(3);
	f_v2_pt_nf3->SetMarkerColor(3);
	v2_pt_nf->Add(f_v2_pt_nf4);

        leg3 = new TLegend(0.5,0.7,0.95,0.9);
        leg3->SetFillColor(0);
        leg3->SetHeader("v2 of partons with different N_{coll} vs final P_{T} region");
        leg3->AddEntry(i_v2_pt_nf1,"Initial v2, N_{coll} = 0","lpe");
        leg3->AddEntry(i_v2_pt_nf2,"Initial v2, N_{coll} = 1","lpe");
        leg3->AddEntry(i_v2_pt_nf3,"Initial v2, N_{coll} = 2","lpe");
        leg3->AddEntry(i_v2_pt_nf4,"Initial v2, N_{coll} >= 3","lpe");
        leg3->AddEntry(f_v2_pt_nf1,"Final v2, N_{coll} = 0","lpe");
        leg3->AddEntry(f_v2_pt_nf2,"Final v2, N_{coll} = 1","lpe");
        leg3->AddEntry(f_v2_pt_nf3,"Final v2, N_{coll} = 2","lpe");
        leg3->AddEntry(f_v2_pt_nf4,"Final v2, N_{coll} >= 3","lpe");


	v2_pt_nf->Draw("apl");
	leg3->Draw("same");
////////////////////////////////////////////////////////////////////////////////////////


}

void v2_n_draw()
{

	TProfile *prof_v2_n_init[6];
	TProfile *prof_v2_n_final[6];
	
	prof_v2_n_init[0] = (TProfile *)gROOT->FindObject("v2_n_init_0");
	prof_v2_n_init[1] = (TProfile *)gROOT->FindObject("v2_n_init_1");
	prof_v2_n_init[2] = (TProfile *)gROOT->FindObject("v2_n_init_2");
	prof_v2_n_init[3] = (TProfile *)gROOT->FindObject("v2_n_init_3");
	prof_v2_n_init[4] = (TProfile *)gROOT->FindObject("v2_n_init_4");
	prof_v2_n_init[5] = (TProfile *)gROOT->FindObject("v2_n_init_5");
	prof_v2_n_final[0] = (TProfile *)gROOT->FindObject("v2_n_final_0");
	prof_v2_n_final[1] = (TProfile *)gROOT->FindObject("v2_n_final_1");
	prof_v2_n_final[2] = (TProfile *)gROOT->FindObject("v2_n_final_2");
	prof_v2_n_final[3] = (TProfile *)gROOT->FindObject("v2_n_final_3");
	prof_v2_n_final[4] = (TProfile *)gROOT->FindObject("v2_n_final_4");
	prof_v2_n_final[5] = (TProfile *)gROOT->FindObject("v2_n_final_5");

	float yi[6][10];
	float yei[6][10];
	float yf[6][10];
	float yef[6][10];
	float xx = prof_v2_n_init[0]->GetBinContent(2);
	cout<<"!!!!!!!!!!!!"<<xx;
	for(int i=0;i<6;i++)
	{
		for(int j=0;j<10;j++)
		{
			yi[i][j] = prof_v2_n_init[i]->GetBinContent(j+1);	
			yei[i][j] = prof_v2_n_init[i]->GetBinError(j+1);	
			yf[i][j] = prof_v2_n_final[i]->GetBinContent(j+1);	
			yef[i][j] = prof_v2_n_final[i]->GetBinError(j+1);	
		}
	}
////////////////Start to work with v2 vs # of collisions//////////////////////
	int nc = 10;
	float nx[10];
	float  nex[10];
	for(int k=0;k<10;k++)
	{
		nx[k] = k;
		nex[k] = 0;
	}
	TCanvas *cv1 = new TCanvas();
	TMultiGraph *v2_n_pti = new TMultiGraph();
	TGraphErrors *i_v2_n_pti1 = new TGraphErrors(nc,nx,yi[0],nex,yei[0]);	
	cout<<"!!!!!!!!!!!!!!!!!!!!!"<<endl;
	i_v2_n_pti1->SetLineColor(1);
	i_v2_n_pti1->SetLineStyle(2);
	i_v2_n_pti1->SetMarkerColor(1);
	v2_n_pti->Add(i_v2_n_pti1);

	TGraphErrors *i_v2_n_pti2 = new TGraphErrors(nc,nx,yi[2],nex,yei[2]);	
	i_v2_n_pti2->SetLineColor(3);
	i_v2_n_pti2->SetLineStyle(2);
	i_v2_n_pti2->SetMarkerColor(1);
	v2_n_pti->Add(i_v2_n_pti2);

	TGraphErrors *i_v2_n_pti3 = new TGraphErrors(nc,nx,yi[4],nex,yei[4]);	
	i_v2_n_pti3->SetLineColor(4);
	i_v2_n_pti3->SetLineStyle(2);
	i_v2_n_pti3->SetMarkerColor(1);
	v2_n_pti->Add(i_v2_n_pti3);

	TGraphErrors *f_v2_n_pti1 = new TGraphErrors(nc,nx,yi[1],nex,yei[1]);	
	f_v2_n_pti1->SetLineColor(1);
	f_v2_n_pti1->SetMarkerColor(1);
	v2_n_pti->Add(f_v2_n_pti1);

	TGraphErrors *f_v2_n_pti2 = new TGraphErrors(nc,nx,yi[3],nex,yei[3]);
	f_v2_n_pti2->SetLineColor(3); 
	f_v2_n_pti2->SetMarkerColor(1);
	v2_n_pti->Add(f_v2_n_pti2);

	TGraphErrors *f_v2_n_pti3 = new TGraphErrors(nc,nx,yi[5],nex,yei[5]);	
	f_v2_n_pti3->SetLineColor(4);
	f_v2_n_pti3->SetMarkerColor(1);
	v2_n_pti->Add(f_v2_n_pti3);

        leg0 = new TLegend(0.5,0.7,0.95,0.9);
        leg0->SetFillColor(0);
        leg0->SetHeader("v2 vs Number of collisions in different initial P_{T} region");
        leg0->AddEntry(i_v2_n_pti1,"Initial v2, 0 GeV < P_{T} < 0.5 GeV","lpe");
        leg0->AddEntry(i_v2_n_pti2,"Initial v2, 1 GeV < P_{T} < 2 GeV","lpe");
        leg0->AddEntry(i_v2_n_pti3,"Initial v2, 2 GeV < P_{T} < 10 GeV","lpe");
        leg0->AddEntry(f_v2_n_pti1,"Final v2, 0 GeV < P_{T} < 0.5 GeV","lpe");
        leg0->AddEntry(f_v2_n_pti2,"Final v2, 1 GeV < P_{T} < 2 GeV","lpe");
        leg0->AddEntry(f_v2_n_pti3,"Final v2, 2 GeV < P_{T} < 10 GeV","lpe");

	v2_n_pti->Draw("apl");
	leg0->Draw("same");
////////////////////////////////////////////////////////////////////////////////////
	TCanvas *cv2 = new TCanvas();

	TMultiGraph *v2_n_ptf = new TMultiGraph();
	int nc = 10;
	TGraphErrors *i_v2_n_ptf1 = new TGraphErrors(nc,nx,yf[0],yef[0]);	
	i_v2_n_ptf1->SetLineColor(1);
	i_v2_n_ptf1->SetLineStyle(2);
	i_v2_n_ptf1->SetMarkerColor(1);
	v2_n_ptf->Add(i_v2_n_ptf1);

	TGraphErrors *i_v2_n_ptf2 = new TGraphErrors(nc,nx,yf[2],nex,yef[2]);	
	i_v2_n_ptf2->SetLineColor(3);
	i_v2_n_ptf2->SetLineStyle(2);
	i_v2_n_ptf2->SetMarkerColor(1);
	v2_n_ptf->Add(i_v2_n_ptf2);

	TGraphErrors *i_v2_n_ptf3 = new TGraphErrors(nc,nx,yf[4],nex,yef[4]);	
	i_v2_n_ptf3->SetLineColor(4);
	i_v2_n_ptf3->SetLineStyle(2);
	i_v2_n_ptf3->SetMarkerColor(1);
	v2_n_ptf->Add(i_v2_n_ptf3);

	TGraphErrors *f_v2_n_ptf1 = new TGraphErrors(nc,nx,yf[1],nex,yef[1]);	
	f_v2_n_ptf1->SetLineColor(1);
	f_v2_n_ptf1->SetMarkerColor(1);
	v2_n_ptf->Add(f_v2_n_ptf1);

	TGraphErrors *f_v2_n_ptf2 = new TGraphErrors(nc,nx,yf[3],nex,yef[3]);	
	f_v2_n_ptf2->SetLineColor(3);
	f_v2_n_ptf2->SetMarkerColor(1);
	v2_n_ptf->Add(f_v2_n_ptf2);

	TGraphErrors *f_v2_n_ptf3 = new TGraphErrors(nc,nx,yf[5],nex,yef[5]);	
	f_v2_n_ptf3->SetLineColor(4);
	f_v2_n_ptf3->SetMarkerColor(1);
	v2_n_ptf->Add(f_v2_n_ptf3);

        leg1 = new TLegend(0.5,0.7,0.95,0.9);
        leg1->SetFillColor(0);
        leg1->SetHeader("v2 vs Number of collisions in different final P_{T} region");
        leg1->AddEntry(i_v2_n_ptf1,"Initial v2, 0 GeV < P_{T} < 0.5 GeV","lpe");
        leg1->AddEntry(i_v2_n_ptf2,"Initial v2, 1 GeV < P_{T} < 2 GeV","lpe");
        leg1->AddEntry(i_v2_n_ptf3,"Initial v2, 2 GeV < P_{T} < 10 GeV","lpe");
        leg1->AddEntry(f_v2_n_ptf1,"Final v2, 0 GeV < P_{T} < 0.5 GeV","lpe");
        leg1->AddEntry(f_v2_n_ptf2,"Final v2, 1 GeV < P_{T} < 2 GeV","lpe");
        leg1->AddEntry(f_v2_n_ptf3,"Final v2, 2 GeV < P_{T} < 10 GeV","lpe");


	v2_n_ptf->Draw("apl");
	leg1->Draw("same");

}

void v2_pt_draw()
{

	TProfile *prof_v2_pt_init[8];
	TProfile *prof_v2_pt_final[8];
	
	prof_v2_pt_init[0] = (TProfile *)gROOT->FindObject("v2_pt_init_0");
	prof_v2_pt_init[1] = (TProfile *)gROOT->FindObject("v2_pt_init_1");
	prof_v2_pt_init[2] = (TProfile *)gROOT->FindObject("v2_pt_init_2");
	prof_v2_pt_init[3] = (TProfile *)gROOT->FindObject("v2_pt_init_3");
	prof_v2_pt_init[4] = (TProfile *)gROOT->FindObject("v2_pt_init_4");
	prof_v2_pt_init[5] = (TProfile *)gROOT->FindObject("v2_pt_init_5");
	prof_v2_pt_init[6] = (TProfile *)gROOT->FindObject("v2_pt_init_6");
	prof_v2_pt_init[7] = (TProfile *)gROOT->FindObject("v2_pt_init_7");
	prof_v2_pt_final[0] = (TProfile *)gROOT->FindObject("v2_pt_final_0");
	prof_v2_pt_final[1] = (TProfile *)gROOT->FindObject("v2_pt_final_1");
	prof_v2_pt_final[2] = (TProfile *)gROOT->FindObject("v2_pt_final_2");
	prof_v2_pt_final[3] = (TProfile *)gROOT->FindObject("v2_pt_final_3");
	prof_v2_pt_final[4] = (TProfile *)gROOT->FindObject("v2_pt_final_4");
	prof_v2_pt_final[5] = (TProfile *)gROOT->FindObject("v2_pt_final_5");
	prof_v2_pt_final[6] = (TProfile *)gROOT->FindObject("v2_pt_final_6");
	prof_v2_pt_final[7] = (TProfile *)gROOT->FindObject("v2_pt_final_7");

	float yi[8][26];
	float yei[8][26];
	float yf[8][26];
	float yef[8][26];
	for(int i=0;i<8;i++)
	{
		for(int j=0;j<26;j++)
		{
			yi[i][j] = prof_v2_pt_init[i]->GetBinContent(j+1);	
			yei[i][j] = prof_v2_pt_init[i]->GetBinError(j+1);	
			yf[i][j] = prof_v2_pt_final[i]->GetBinContent(j+1);	
			yef[i][j] = prof_v2_pt_final[i]->GetBinError(j+1);	
		}
	}
	
////////////////Start to work with v2 vs # of collisions//////////////////////
        float ptx[27];
	float ptex[27];
	for(int i=0;i<20;i++)
     		ptx[i] = 0.1*i;
	for(int i=20;i<25;i++)
     		ptx[i] = 0.4 * i-6.;
	ptx[25] = 4.;
	ptx[26] = 6.;

	for(int k=0;k<27;k++)
	{
		ptex[k] = 0;
	}
	TCanvas *cv3 = new TCanvas();
	TMultiGraph *v2_pt_ni = new TMultiGraph();
	int nc = 26;
	TGraphErrors *i_v2_pt_ni1 = new TGraphErrors(nc,ptx,yi[0],ptex,yei[0]);	
	cout<<"!!!!!!!!!!!!!!!!!!!!!"<<endl;
	i_v2_pt_ni1->SetLineColor(1);
	i_v2_pt_ni1->SetLineStyle(2);
	i_v2_pt_ni1->SetMarkerColor(1);
	v2_pt_ni->Add(i_v2_pt_ni1);

	TGraphErrors *i_v2_pt_ni2 = new TGraphErrors(nc,ptx,yi[2],ptex,yei[2]);	
	i_v2_pt_ni2->SetLineColor(2);
	i_v2_pt_ni2->SetLineStyle(2);
	i_v2_pt_ni2->SetMarkerColor(2);
	v2_pt_ni->Add(i_v2_pt_ni2);

	TGraphErrors *i_v2_pt_ni3 = new TGraphErrors(nc,ptx,yi[4],ptex,yei[4]);	
	i_v2_pt_ni3->SetLineColor(4);
	i_v2_pt_ni3->SetLineStyle(2);
	i_v2_pt_ni3->SetMarkerColor(4);
	v2_pt_ni->Add(i_v2_pt_ni3);

	TGraphErrors *i_v2_pt_ni4 = new TGraphErrors(nc,ptx,yi[6],ptex,yei[6]);	
	i_v2_pt_ni4->SetLineColor(3);
	i_v2_pt_ni4->SetLineStyle(2);
	i_v2_pt_ni4->SetMarkerColor(3);
	v2_pt_ni->Add(i_v2_pt_ni4);

	TGraphErrors *f_v2_pt_ni1 = new TGraphErrors(nc,ptx,yi[1],ptex,yei[1]);	
	f_v2_pt_ni1->SetLineColor(1);
	f_v2_pt_ni1->SetMarkerColor(1);
	v2_pt_ni->Add(f_v2_pt_ni1);

	TGraphErrors *f_v2_pt_ni2 = new TGraphErrors(nc,ptx,yi[3],ptex,yei[3]);	
	f_v2_pt_ni2->SetLineColor(2);
	f_v2_pt_ni2->SetMarkerColor(2);
	v2_pt_ni->Add(f_v2_pt_ni2);

	TGraphErrors *f_v2_pt_ni3 = new TGraphErrors(nc,ptx,yi[5],ptex,yei[5]);	
	f_v2_pt_ni3->SetLineColor(4);
	f_v2_pt_ni3->SetMarkerColor(4);
	v2_pt_ni->Add(f_v2_pt_ni3);

	TGraphErrors *f_v2_pt_ni4 = new TGraphErrors(nc,ptx,yi[7],ptex,yei[7]);	
	f_v2_pt_ni4->SetLineColor(3);
	f_v2_pt_ni4->SetMarkerColor(3);
	v2_pt_ni->Add(f_v2_pt_ni4);

        leg2 = new TLegend(0.5,0.7,0.95,0.9);
        leg2->SetFillColor(0);
        leg2->SetHeader("v2 of partons with different N_{coll} vs initial P_{T} region");
        leg2->AddEntry(i_v2_pt_ni1,"Initial v2, N_{coll} = 0","lpe");
        leg2->AddEntry(i_v2_pt_ni2,"Initial v2, N_{coll} = 1","lpe");
        leg2->AddEntry(i_v2_pt_ni3,"Initial v2, N_{coll} = 2","lpe");
        leg2->AddEntry(i_v2_pt_ni4,"Initial v2, N_{coll} >= 3","lpe");
        leg2->AddEntry(f_v2_pt_ni1,"Final v2, N_{coll} = 0","lpe");
        leg2->AddEntry(f_v2_pt_ni2,"Final v2, N_{coll} = 1","lpe");
        leg2->AddEntry(f_v2_pt_ni3,"Final v2, N_{coll} = 2","lpe");
        leg2->AddEntry(f_v2_pt_ni4,"Final v2, N_{coll} >= 3","lpe");

	v2_pt_ni->Draw("apl");
	leg2->Draw("same");
////////////////////////////////////////////////////////////////////////////////////
	TCanvas *cv2 = new TCanvas();

	TMultiGraph *v2_pt_nf = new TMultiGraph();
	int nc = 26;
	TGraphErrors *i_v2_pt_nf1 = new TGraphErrors(nc,ptx,yf[0],ptex,yef[0]);	
	i_v2_pt_nf1->SetLineColor(1);
	i_v2_pt_nf1->SetLineStyle(2);
	i_v2_pt_nf1->SetMarkerColor(1);
	v2_pt_nf->Add(i_v2_pt_nf1);

	TGraphErrors *i_v2_pt_nf2 = new TGraphErrors(nc,ptx,yf[2],ptex,yef[2]);	
	i_v2_pt_nf2->SetLineColor(2);
	i_v2_pt_nf2->SetLineStyle(2);
	i_v2_pt_nf2->SetMarkerColor(2);
	v2_pt_nf->Add(i_v2_pt_nf2);

	TGraphErrors *i_v2_pt_nf3 = new TGraphErrors(nc,ptx,yf[4],ptex,yef[4]);	
	i_v2_pt_nf3->SetLineColor(4);
	i_v2_pt_nf3->SetLineStyle(2);
	i_v2_pt_nf3->SetMarkerColor(4);
	v2_pt_nf->Add(i_v2_pt_nf3);

	TGraphErrors *i_v2_pt_nf4 = new TGraphErrors(nc,ptx,yf[6],ptex,yef[6]);	
	i_v2_pt_nf4->SetLineColor(3);
	i_v2_pt_nf4->SetLineStyle(2);
	i_v2_pt_nf4->SetMarkerColor(3);
	v2_pt_nf->Add(i_v2_pt_nf4);

	TGraphErrors *f_v2_pt_nf1 = new TGraphErrors(nc,ptx,yf[1],ptex,yef[1]);	
	f_v2_pt_nf1->SetLineColor(1);
	f_v2_pt_nf1->SetMarkerColor(1);
	v2_pt_nf->Add(f_v2_pt_nf1);

	TGraphErrors *f_v2_pt_nf2 = new TGraphErrors(nc,ptx,yf[3],ptex,yef[3]);	
	f_v2_pt_nf2->SetLineColor(2);
	f_v2_pt_nf2->SetMarkerColor(2);
	v2_pt_nf->Add(f_v2_pt_nf2);

	TGraphErrors *f_v2_pt_nf3 = new TGraphErrors(nc,ptx,yf[5],ptex,yef[5]);	
	f_v2_pt_nf3->SetLineColor(4);
	f_v2_pt_nf3->SetMarkerColor(4);
	v2_pt_nf->Add(f_v2_pt_nf3);

	TGraphErrors *f_v2_pt_nf4 = new TGraphErrors(nc,ptx,yf[7],ptex,yef[7]);	
	f_v2_pt_nf4->SetLineColor(3);
	f_v2_pt_nf4->SetMarkerColor(3);
	v2_pt_nf->Add(f_v2_pt_nf4);

        leg3 = new TLegend(0.5,0.7,0.95,0.9);
        leg3->SetFillColor(0);
        leg3->SetHeader("v2 of partons with different N_{coll} vs final P_{T} region");
        leg3->AddEntry(i_v2_pt_nf1,"Initial v2, N_{coll} = 0","lpe");
        leg3->AddEntry(i_v2_pt_nf2,"Initial v2, N_{coll} = 1","lpe");
        leg3->AddEntry(i_v2_pt_nf3,"Initial v2, N_{coll} = 2","lpe");
        leg3->AddEntry(i_v2_pt_nf4,"Initial v2, N_{coll} >= 3","lpe");
        leg3->AddEntry(f_v2_pt_nf1,"Final v2, N_{coll} = 0","lpe");
        leg3->AddEntry(f_v2_pt_nf2,"Final v2, N_{coll} = 1","lpe");
        leg3->AddEntry(f_v2_pt_nf3,"Final v2, N_{coll} = 2","lpe");
        leg3->AddEntry(f_v2_pt_nf4,"Final v2, N_{coll} >= 3","lpe");


	v2_pt_nf->Draw("apl");
	leg3->Draw("same");
////////////////////////////////////////////////////////////////////////////////////////

}
void v2_N()
{
	TProfile *prof_iv2_n[3];
	TProfile *prof_fv2_n[3];
	prof_iv2_n[0] = (TProfile *)gROOT->FindObject("iv2_n_0");
	prof_iv2_n[1] = (TProfile *)gROOT->FindObject("iv2_n_1");
	prof_iv2_n[2] = (TProfile *)gROOT->FindObject("iv2_n_2");
	prof_fv2_n[0] = (TProfile *)gROOT->FindObject("fv2_n_0");
	prof_fv2_n[1] = (TProfile *)gROOT->FindObject("fv2_n_1");
	prof_fv2_n[2] = (TProfile *)gROOT->FindObject("fv2_n_2");
	int nc = 10;
	float iy[3][10];
	float iye[3][10];
	float ix[10];
	float ixe[10];
	for(int i=0;i<10;i++)
	{
		ix[i] = i;
		ixe[i] = 0;
		for(int j=0;j<3;j++)
		{
			iy[j][i] = prof_iv2_n[j]->GetBinContent(i+1);
			iye[j][i] = prof_iv2_n[j]->GetBinError(i+1);
		}
	}	
	float fy[3][10];
	float fye[3][10];
	float fx[10];
	float fxe[10];
	for(int i=0;i<10;i++)
	{
		fx[i] = i;
		fxe[i] = 0;
		for(int j=0;j<3;j++)
		{
			fy[j][i] = prof_fv2_n[j]->GetBinContent(i+1);
			fye[j][i] = prof_fv2_n[j]->GetBinError(i+1);
		}
	}	

	TCanvas *cv1 = new TCanvas();
        TMultiGraph *v2_n_pti = new TMultiGraph();
        TGraphErrors *i_v2_n_pti1 = new TGraphErrors(nc,ix,iy[0],ixe,iye[0]);
        i_v2_n_pti1->SetLineColor(1);
        i_v2_n_pti1->SetLineStyle(2);
        i_v2_n_pti1->SetMarkerColor(1);
        v2_n_pti->Add(i_v2_n_pti1);

        TGraphErrors *i_v2_n_pti2 = new TGraphErrors(nc,ix,iy[1],ixe,iye[1]);
        i_v2_n_pti2->SetLineColor(2);
        i_v2_n_pti2->SetLineStyle(2);
        i_v2_n_pti2->SetMarkerColor(2);
        v2_n_pti->Add(i_v2_n_pti2);

        TGraphErrors *i_v2_n_pti3 = new TGraphErrors(nc,ix,iy[2],ixe,iye[2]);
        i_v2_n_pti3->SetLineColor(3);
        i_v2_n_pti3->SetLineStyle(2);
        i_v2_n_pti3->SetMarkerColor(3);
        v2_n_pti->Add(i_v2_n_pti3);

        TMultiGraph *v2_n_ptf = new TMultiGraph();
        TGraphErrors *i_v2_n_ptf1 = new TGraphErrors(nc,fx,fy[0],fxe,fye[0]);
        i_v2_n_ptf1->SetLineColor(1);
        i_v2_n_ptf1->SetMarkerColor(1);
        v2_n_pti->Add(i_v2_n_ptf1);

        TGraphErrors *i_v2_n_ptf2 = new TGraphErrors(nc,fx,fy[1],fxe,fye[1]);
        i_v2_n_ptf2->SetLineColor(2);
        i_v2_n_ptf2->SetMarkerColor(2);
        v2_n_pti->Add(i_v2_n_ptf2);

        TGraphErrors *i_v2_n_ptf3 = new TGraphErrors(nc,fx,fy[2],fxe,fye[2]);
        i_v2_n_ptf3->SetLineColor(3);
        i_v2_n_ptf3->SetMarkerColor(3);
        v2_n_pti->Add(i_v2_n_ptf3);


	leg0 = new TLegend(0.5,0.7,0.95,0.9);
        leg0->SetFillColor(0);
        leg0->SetHeader("v2 vs Number of collisions in different initial P_{T} region");
        leg0->AddEntry(i_v2_n_pti1,"v2, 0 GeV < P_{T} < 0.5 GeV, initial P_{T}","lpe");
        leg0->AddEntry(i_v2_n_pti2,"v2, 1 GeV < P_{T} < 2 GeV, initial P_{T}","lpe");
        leg0->AddEntry(i_v2_n_pti3,"v2, 2 GeV < P_{T} < 10 GeV, initial P_{T}","lpe");
        leg0->AddEntry(i_v2_n_ptf1,"v2, 0 GeV < P_{T} < 0.5 GeV, final P_{T}","lpe");
        leg0->AddEntry(i_v2_n_ptf2,"v2, 1 GeV < P_{T} < 2 GeV,final P_{T}","lpe");
        leg0->AddEntry(i_v2_n_ptf3,"v2, 2 GeV < P_{T} < 10 GeV,final P_{T}","lpe");

	v2_n_pti->Draw("apl");
	leg0->Draw("same");
	cout<<"$$$$$$$$$$$$$$ = "<<iy[0][0]<<endl;
}



void rptN_draw()
{
	//TCanvas *c = new TCanvas();	
	//c->Divide(2,2);
	TMultiGraph *mmg = new TMultiGraph();
        TProfile *dptvsN_1 = (TProfile *)gROOT->FindObject("dptvsN_1");
        TProfile *dptvsN_2 = (TProfile *)gROOT->FindObject("dptvsN_2");
        TProfile *dptvsN_3 = (TProfile *)gROOT->FindObject("dptvsN_3");
        TProfile *dptvsN_4 = (TProfile *)gROOT->FindObject("dptvsN_4");
        TProfile *iptvsN_1 = (TProfile *)gROOT->FindObject("iptvsN_1");
        TProfile *iptvsN_2 = (TProfile *)gROOT->FindObject("iptvsN_2");
        TProfile *iptvsN_3 = (TProfile *)gROOT->FindObject("iptvsN_3");
        TProfile *iptvsN_4 = (TProfile *)gROOT->FindObject("iptvsN_4");

	int nc = 10;
	double x[4][10],y[4][10],ex[4][10],ey[4][10];
	for(int j=0;j<10;j++)
	{
		for(int i=0;i<4;i++)
		{
			x[i][j] = j;
			ex[i][j] = 0;
		}
		y[0][j] = dptvsN_1->GetBinContent(j+1) / (iptvsN_1->GetBinContent(j+1)-0.3087) ;
		y[1][j] = dptvsN_2->GetBinContent(j+1) / (iptvsN_2->GetBinContent(j+1)-0.3087) ;
		y[2][j] = dptvsN_3->GetBinContent(j+1) / (iptvsN_3->GetBinContent(j+1)-0.3087) ;
		y[3][j] = dptvsN_4->GetBinContent(j+1) / (iptvsN_4->GetBinContent(j+1)-0.3087) ;
		ey[0][j] = dptvsN_1->GetBinError(j+1) + iptvsN_1->GetBinError(j+1);
		ey[1][j] = dptvsN_2->GetBinError(j+1) + iptvsN_2->GetBinError(j+1);
		ey[2][j] = dptvsN_3->GetBinError(j+1) + iptvsN_3->GetBinError(j+1);
		ey[3][j] = dptvsN_4->GetBinError(j+1) + iptvsN_4->GetBinError(j+1);
	}
	y[0][0] = 0;
	y[1][0] = 0;
	y[2][0] = 0;
	y[3][0] = 0;

	TGraphErrors *gr0 = new TGraphErrors(nc,x[0],y[0],ex[0],ey[0]);
	gr0->GetXaxis()->SetTitle("Number of Collision");	
	gr0->GetYaxis()->SetTitle("(P_{T}^{final}-P_{T}^{initial})/(P_{T}^{initial}-<P_{T}>");	
        gr0->SetTitle("Initial P_{T} < 0.2GeV");
	mmg->Add(gr0);


	TGraphErrors *gr1 = new TGraphErrors(nc,x[1],y[1],ex[1],ey[1]);
	gr1->GetXaxis()->SetTitle("Number of Collision");	
	gr1->GetYaxis()->SetTitle("(P_{T}^{final}-P_{T}^{initial})/(P_{T}^{initial}-<P_{T}>");	
        gr1->SetTitle("Initial P_{T} > 1GeV");
        gr1->SetLineColor(2);
        gr1->SetMarkerColor(2);
	mmg->Add(gr1);


	TGraphErrors *gr2 = new TGraphErrors(nc,x[2],y[2],ex[2],ey[2]);
	gr2->GetXaxis()->SetTitle("Number of Collision");	
	gr2->GetYaxis()->SetTitle("(P_{T}^{final}-P_{T}^{initial})/(P_{T}^{initial}-<P_{T}>");	
        gr2->SetTitle("Initial P_{T} > 2GeV");
        gr2->SetLineColor(3);
        gr2->SetMarkerColor(3);
	mmg->Add(gr2);


	TGraphErrors *gr3 = new TGraphErrors(nc,x[3],y[3],ex[3],ey[3]);
	gr3->GetXaxis()->SetTitle("Number of Collision");	
	gr3->GetYaxis()->SetTitle("(P_{T}^{final}-P_{T}^{initial})/(P_{T}^{initial}-<P_{T}>");	
        gr3->SetTitle("Initial P_{T} > 3GeV");
        gr3->SetLineColor(4);
        gr3->SetMarkerColor(4);
	mmg->Add(gr3);


	leg0 = new TLegend(0.5,0.7,0.95,0.9);
        leg0->SetFillColor(0);
        leg0->AddEntry(gr0,"Initial P_{T}<0.2GeV","lpe");
        leg0->AddEntry(gr1,"Initial P_{T}>1GeV","lpe");
        leg0->AddEntry(gr2,"Initial P_{T}>2GeV","lpe");
        leg0->AddEntry(gr3,"Initial P_{T}>3GeV","lpe");
	mmg->Draw("apl");
        leg0->Draw("same");
/*
        c->cd(1);
        gr0->Draw("apl");
        c->cd(2);
        gr1->Draw("apl");
        c->cd(3);
        gr2->Draw("apl");
        c->cd(4);
        gr3->Draw("apl");	
*/
}


void nVsDpt_draw()
{
	//TCanvas *c = new TCanvas();	
	//c->Divide(2,2);
	TMultiGraph *mmg = new TMultiGraph();
        TProfile *nVspt_1 = (TProfile *)gROOT->FindObject("nVsDpt_1");
        TProfile *nVspt_2 = (TProfile *)gROOT->FindObject("nVsDpt_2");
        TProfile *nVspt_3 = (TProfile *)gROOT->FindObject("nVsDpt_3");
        TProfile *nVspt_4 = (TProfile *)gROOT->FindObject("nVsDpt_4");

	double x[4][binNumber],y[4][binNumber],ex[4][binNumber],ey[4][binNumber];
	for(int j=0;j<binNumber;j++)
	{
		for(int i=0;i<4;i++)
		{
			x[i][j] = 0.25 * j -4;
			ex[i][j] = 0;
		}
		y[0][j] = nVspt_1->GetBinContent(j+1) ;
		y[1][j] = nVspt_2->GetBinContent(j+1) ;
		y[2][j] = nVspt_3->GetBinContent(j+1) ;
		y[3][j] = nVspt_4->GetBinContent(j+1) ;
		ey[0][j] = nVspt_1->GetBinError(j+1);
		ey[1][j] = nVspt_2->GetBinError(j+1);
		ey[2][j] = nVspt_3->GetBinError(j+1);
		ey[3][j] = nVspt_4->GetBinError(j+1);
	}

	TGraphErrors *gr0 = new TGraphErrors(binNumber,x[0],y[0],ex[0],ey[0]);
	gr0->GetXaxis()->SetTitle("Number of Collision");	
	gr0->GetYaxis()->SetTitle("(P_{T}^{final}-P_{T}^{initial})/(P_{T}^{initial}-<P_{T}>");	
        gr0->SetTitle("Initial P_{T} < 0.2GeV");
	mmg->Add(gr0);


	TGraphErrors *gr1 = new TGraphErrors(binNumber,x[1],y[1],ex[1],ey[1]);
	gr1->GetXaxis()->SetTitle("Number of Collision");	
	gr1->GetYaxis()->SetTitle("(P_{T}^{final}-P_{T}^{initial})/(P_{T}^{initial}-<P_{T}>");	
        gr1->SetTitle("Initial P_{T} > 1GeV");
        gr1->SetLineColor(2);
        gr1->SetMarkerColor(2);
	mmg->Add(gr1);


	TGraphErrors *gr2 = new TGraphErrors(binNumber,x[2],y[2],ex[2],ey[2]);
	gr2->GetXaxis()->SetTitle("Number of Collision");	
	gr2->GetYaxis()->SetTitle("(P_{T}^{final}-P_{T}^{initial})/(P_{T}^{initial}-<P_{T}>");	
        gr2->SetTitle("Initial P_{T} > 2GeV");
        gr2->SetLineColor(3);
        gr2->SetMarkerColor(3);
	mmg->Add(gr2);


	TGraphErrors *gr3 = new TGraphErrors(binNumber,x[3],y[3],ex[3],ey[3]);
	gr3->GetXaxis()->SetTitle("Number of Collision");	
	gr3->GetYaxis()->SetTitle("(P_{T}^{final}-P_{T}^{initial})/(P_{T}^{initial}-<P_{T}>");	
        gr3->SetTitle("Initial P_{T} > 3GeV");
        gr3->SetLineColor(4);
        gr3->SetMarkerColor(4);
	mmg->Add(gr3);


	leg0 = new TLegend(0.5,0.7,0.95,0.9);
        leg0->SetFillColor(0);
        leg0->AddEntry(gr0,"Initial P_{T}<0.2GeV","lpe");
        leg0->AddEntry(gr1,"Initial P_{T}>1GeV","lpe");
        leg0->AddEntry(gr2,"Initial P_{T}>2GeV","lpe");
        leg0->AddEntry(gr3,"Initial P_{T}>3GeV","lpe");
	mmg->Draw("apl");
        leg0->Draw("same");
/*
        c->cd(1);
        gr0->Draw("apl");
        c->cd(2);
        gr1->Draw("apl");
        c->cd(3);
        gr2->Draw("apl");
        c->cd(4);
        gr3->Draw("apl");	
*/
}
